
CREATE
	OR REPLACE FUNCTION boolean_to_bigint ( BOOLEAN ) RETURNS BIGINT AS $$ SELECT
	( CASE WHEN $1 :: BOOLEAN = 'f' :: BOOLEAN THEN 0 :: BIGINT ELSE 1 :: BIGINT END ) $$ LANGUAGE SQL STRICT;
CREATE CAST ( BOOLEAN AS BIGINT ) WITH FUNCTION boolean_to_bigint ( BOOLEAN ) AS IMPLICIT;

CREATE
	OR REPLACE FUNCTION bigint_to_boolean(BIGINT) RETURNS  BOOLEAN  AS $$ SELECT
	( CASE WHEN $1 :: BIGINT = 0 :: BIGINT  THEN 'f' :: BOOLEAN ELSE 't' :: BOOLEAN END ) $$ LANGUAGE SQL STRICT;
CREATE CAST ( BIGINT AS BOOLEAN  ) WITH FUNCTION bigint_to_boolean ( BIGINT ) AS IMPLICIT;